﻿@{
    ViewBag.Title = "Manage Department - Department Management System";
    Layout = "~/Views/Shared/_Layout.cshtml";
    
}
<h2>
    Manage Department</h2>
<form action="" method="post" id="form" name="formDepartment">
<input type="hidden" id="Action" name="Action" />
<ul class="shortcut-buttons-set">
    <li><a class="shortcut-button" href="@Url.Action("AddDepartment", "Setting")"><span>
        <img src="../../Content/images/icons/Button-Add-icon.png" alt="icon" /><br />
        Add</span></a></li>
    <li><a class="shortcut-button" href="#" onclick="if(DoAction('@Url.Action("EditDepartment", "Setting")')==-1)jAlert('Please Select One Item', 'Message');">
        <span>
            <img src="../../Content/images/icons/paper_content_pencil_48.png" alt="icon" /><br />
            Edit</span></a></li>
    <li><a class="shortcut-button" href="javascript:Action('Delete')"><span>
        <img src="../../Content/images/icons/Button-Close-icon.png" alt="icon" /><br />
        Delete</span></a></li>
</ul>
<!-- End .shortcut-buttons-set -->
<div class="clear">
</div>
<!-- End .clear -->
<!-- Search -->
<input type="hidden" id="isSearch" name="isSearch" value="@ViewData["IsSearch"]" />
<div class="content-box" id="Search">
    <!-- Start Content Box -->
    <div class="content-box-header">
        <h3 id="toggleSearch">
            Search</h3>
        <div class="clear">
        </div>
    </div>
    <!-- End .content-box-header -->
    <div class="content-box-content">
        <fieldset>
            <p>
                <label class="width12 floatLeft">
                    Department :</label>
                <input type="text" id="txtDepartmentName" name="DepartmentName" class="width20 input-inline text-input medium-input" value="@ViewData["DepartmentName"]"/>
            </p>
        </fieldset>
    </div>
</div>
<div class="content-box">
    <!-- Start Content Box -->
    <div class="content-box-header">
        <h3>
            Department List</h3>
        <div class="clear">
        </div>
    </div>
    <!-- End .content-box-header -->
    <div class="content-box-content">
        <div>
            <!-- This is the target div. id must match the href of this div's tab -->
            @{ if (TempData["Message"] != null)
               {
                <div class="notification attention png_bg">
                    <a href="#" class="close">
                        <img src="../../Content/images/icons/cross_grey_small.png" title="Close this notification"
                            alt="close" /></a>
                    <div>
                        @TempData["Message"].ToString()
                    </div>
                </div>
               }
            }
            @{ 
                var pageSize = int.Parse(ViewData[PMS.ENT.PageInfo.PageSize.ToString()].ToString());
                var pageNum = int.Parse(ViewData[PMS.ENT.PageInfo.PageNum.ToString()].ToString());
                var page = int.Parse(ViewData[PMS.ENT.PageInfo.Page.ToString()].ToString()); }
          @*  <input type="hidden" name="DepartmentID" id="DepartmentID" />*@
            <input type="hidden" value="@ViewData["OrderBy"]" name="orderBy" id="orderBy" />
            <input type="hidden" value="@ViewData["OrderDirection"]" name="orderDirection"
                id="orderDirection" />
            @{if (Model.Count <= 0)
              {
                <div class="RecordFound @("RecordFound" + @Model.Count)">
                    No Record Found</div>
              }
            }
            <table class="flexigird TableGrid">
                <thead>
                    <tr>
                        <th id="Selected">
                            <input class="check-all" type="checkbox" id="checkAll" />
                        </th>
                        <th id="DepartmentName">
                            Department 
                        </th>
                    </tr>
                </thead>
                @*<tfoot>
                    <tr>
                        <td colspan="6">
                            @{ Html.RenderPartial("Pagination", null, ViewData); }
                            <!-- End .pagination -->
                            <div class="clear">
                            </div>
                        </td>
                    </tr>
                </tfoot>*@
                <tbody>
                    @{ for (int i = 0; i < Model.Count; i++)
                       {
                           string Departmentname = Model[i].DepartmentName;
                        <tr>
                            <td>
                                <input type="checkbox" id="DepartmentID" name="DepartmentID" value="@Model[i].DepartmentID"
                                        group="Selected" onclick="Uncheck('DepartmentID');" />
                            </td>
                            <td>
                                @Html.ActionLink(Departmentname, "ViewDepartment", new { ID = Model[i].DepartmentID }, null)
                            </td>
                        </tr>
                       } 
                    }
                </tbody>
            </table>
            @{Html.RenderPartial("Pagination", null, ViewData); }
        </div>
        <!-- End #tab1 -->
    </div>
    <!-- End .content-box-content -->
</div>
<!-- End .content-box -->
</form>
<script language="javascript" type="text/javascript">
    $("#Setting").addClass("current");
    $("#ManageDepartment").addClass("current");
    $("#toggleSearch").click(function () {
        if ($("#isSearch").val() == 1) {
            $("#isSearch").val(0);
        }
        else {
            $("#isSearch").val(1);
        }
    });
     $('#txtDepartmentName').keydown(function(event) {
         if (event.keyCode == 13) {
            $('form').submit(); 
         }
     });
   
    var isSearch = @ViewData["IsSearch"];
    if (isSearch == '1') {
        $("#Search").removeClass('closed-box');
    }
    else {
        $("#Search").addClass('closed-box');
    }

    
  
</script>
